#include <iostream>
#include <list>

using std::cout;
using std::endl;
using std::list;

void test()
{
    //1、初始化
    //1.1、创建一个空对象
    /* list<int> number; */
    //1.2、创建count个value
    /* list<int> number(10, 3); */
    /* list<int> number(10); */
    //1.3、迭代器范围
    /* int arr[10] = {1, 3, 5, 7, 9, 2, 4, 6, 8, 10}; */
    /* list<int> number(arr, arr + 10);//[,)左闭右开 */
    //1.4、使用大括号
    list<int> number = {1, 2, 3, 5, 6, 8, 7, 4};

    //2、遍历
    //2.1、下标
    /* for(size_t idx = 0; idx != number.size(); ++idx) */
    /* { */
    /*     cout << number[idx] << "  "; */
    /* } */
    /* cout << endl; */

    //2.2、迭代器
    //y/d + 目标行号 + G
    list<int>::iterator it;
    for(it = number.begin(); it != number.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    list<int>::iterator it2 = number.begin();
    for(; it2 != number.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //3、for与auto
    for(auto &elem : number)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

